#!/usr/bin/env python
#coding=utf-8

import os,sys
from time import strftime, localtime

#写入日志
def wlog(file):
    strLogfileName = strftime("%Y-%m-%d.txt",localtime())
    dt = strftime("%Y-%m-%d %H:%M:%S",localtime())
    fp=open(strLogfileName,'a') 
    fp.write(dt +' ') 
    fp.write(file + '\n') 
    fp.close()

#取到当前目录
def runpath():
    path = sys.path[0]
    if os.path.isdir(path):
        return path
    elif os.path.isfile(path):
        return os.path.dirname(path)

#遍历目录
def file_in_folder(folder):
    for root, dis, files in os.walk(folder):  
        for file1 in files:
            if file1 == 'Thumbs.db' :
                thumbs = os.path.join(root, file1)
                print thumbs
                wlog(thumbs)
                os.remove(thumbs)
            
if __name__ == "__main__":
    file_in_folder(runpath())